//
//  ErrorHelpler.m
//  MobaoInteraction
//
//  Created by a on 2019/12/26.
//  Copyright © 2019 mobao. All rights reserved.
//

#import "ErrorHelpler.h"

@implementation ErrorHelpler

+ (NSError *)createError:(NSString *)reason {
    return [ErrorHelpler createError:reason code:-1];
}

+ (NSError *)createError:(NSString *)reason code:(NSInteger)code {
    if (reason) {
        return [NSError errorWithDomain:reason code:code userInfo:@{NSLocalizedDescriptionKey:reason}];
    }
    return nil;
}

+ (void)showError:(NSString *)message {
    [ErrorHelpler message:message code:nil delay:1.5];
}

+ (void)showError:(NSString *)message delay:(NSTimeInterval)delay {
    [ErrorHelpler message:message code:nil delay:delay];
}

+ (void)showError:(NSString *)message code:(NSInteger)code {
    [ErrorHelpler message:message code:@(code) delay:1.5];
}

+ (void)showError:(NSString *)message code:(NSInteger )code delay:(NSTimeInterval)delay {
    [ErrorHelpler message:message code:@(code) delay:delay];
}

+ (void)message:(NSString *)message code:(NSNumber *)code delay:(NSTimeInterval)delay {
    if (message) {
        NSMutableString *string = [NSMutableString stringWithString:message];
        if (code) {
            [string appendFormat:@"(%@)", code];
        }
//        [SVProgressHUD showErrorWithStatus:string];
//        [SVProgressHUD dismissWithDelay:delay];
        NSLog(@"%@", string);
    }
}

@end
